package com.ruoyi.web.controller.teaching;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teaching.domain.PlatformSCollect;
import com.ruoyi.teaching.domain.vo.PlatformCCourseVO;
import com.ruoyi.teaching.service.PlatformSCollectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 王旭
 * @since 2024-06-24
 */
@RestController
@RequestMapping("/platform/collect")
@Api(tags = "platform-收藏管理")
public class PlatformSCollectController {
    @Autowired
    private PlatformSCollectService platformSCollectService;

    /**
     * 查询个人收藏列表
     */
//    @PreAuthorize("@ss.hasPermi('platform:collect:listOwn')")
    @GetMapping("/listOwn")
    @ApiOperation(value = "查询个人收藏列表", notes = "查询个人收藏列表")
    public AjaxResult listOwn(Integer pageNum, Integer pageSize, Integer collectType, Integer choose) {
        return platformSCollectService.listOwn(pageNum, pageSize, collectType, choose);
    }

    /**
     * 新增个人收藏
     */
//    @PreAuthorize("@ss.hasPermi('platform:collect:edit')")
    @Log(title = "【新增个人收藏】", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "新增个人收藏", notes = "新增个人收藏")
    public AjaxResult edit(@RequestBody PlatformSCollect platformSCollect) {
        return platformSCollectService.insertPlatformSCollect(platformSCollect);
    }

    /**
     * 删除个人收藏
     */
//    @PreAuthorize("@ss.hasPermi('platform:collect:remove')")
    @Log(title = "【删除个人收藏】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除个人收藏", notes = "删除个人收藏")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return platformSCollectService.deleteCollectByIds(ids);
    }

    /**
     * 前台删除个人收藏
     */
    @DeleteMapping("/removeFront")
    @ApiOperation(value = "前台删除个人收藏", notes = "前台删除个人收藏")
    public AjaxResult removeFront(Integer collectType,Integer projectId) {
        return platformSCollectService.deleteCollectInFront(collectType,projectId);
    }

}

